package org.flowers.unbeaten.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @description 日期处理工具类
 * @author RyanWang
 * @date 2021-07-16 15:08:59
 * @version 1.0
 */
public class DateUtils {

    /**
     * 时间格式(yyyy-MM-dd HH:mm:ss)
     */
    public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";

    /**
     * 时间格式(yyyyMMdd)
     */
    public final static String DATE_PATTERN = "yyyyMMdd";

    public static String format(Date date, String pattern) {
        if (date != null) {
            SimpleDateFormat df = new SimpleDateFormat(pattern);
            return df.format(date);
        }
        return null;
    }

}
